package com.cq.xjms.model;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/***
 * @author caiqiang
 * @version 1
 */
@Entity
@Table(name = "Teacher")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQueries( {
	@NamedQuery(name = "Teacher.query", query ="select t from Teacher t where  t.teacherNo=:teacherNo"),
	@NamedQuery(name = "Teacher.list", query ="select t from Teacher t order by t.id"),
	@NamedQuery(name = "Teacher.queryById", query ="select t from Teacher t  where t.id=:id"),
	@NamedQuery(name = "Teacher.login", query ="select u from Teacher u where  u.teacherNo=:userNo and u.password=:password ")
})
public class Teacher extends BaseEntity {
	
	private static final long serialVersionUID = 8825616410502042893L;
	
	public static final String TEACHER_QUERY = "Teacher.query";
	public static final String TEACHER_LIST = "Teacher.list";
	public static final String TEACHER_QUERYBYID = "Teacher.queryById";
	public static final String TEACHER_LOGIN = "Teacher.login";
	@Column(name = "NAME", length = 50, nullable = false)
	private String name; 
	
	@Column(name = "PASSWORD", length = 50, nullable = false)
	private String password;
	
	@Column(name = "SEX", length = 50)
	private String sex;
	
	@Column(name = "EMAIL", length = 50)
	private String email;
	
	@Column(name = "TEL", length = 15)
	private String tel;
	
	@Column(name = "PHONE", length = 11)
	private String phone;
	
	@Column(name = "TEACHERNO", length = 20, nullable = false,unique = true)
	private String teacherNo;
	
	@Column(name = "BIRTHDATE")
	@Temporal(TemporalType.DATE)
	private Date birthDate ;
	
	@Column(name = "CREATEDATE", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createDate=new Date();
	
	@Column(name="ADDRESS",length=100)
	private String address;	
	
	@OneToMany(fetch = FetchType.LAZY,mappedBy="teacher")
	private List<Course> courses;
	
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;  
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getTeacherNo() {
		return teacherNo;
	}
	public void setTeacherNo(String teacherNo) {
		this.teacherNo = teacherNo;
	}
	
	public Date getBirthDate() {
		return birthDate;
	}
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}
	public List<Course> getCourses() {
		return courses;
	}
	public void setCourses(List<Course> courses) {
		this.courses = courses;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	
	
}
